-- Add new int field
IF NOT EXISTS(SELECT [Name] FROM syscolumns WHERE Name = 'FromShopId' AND ID = OBJECT_ID('dbo.InOutProdPaper'))
   ALTER TABLE InOutProdPaper ADD FromShopId INT NULL
   
-- Add new int field
IF NOT EXISTS(SELECT [Name] FROM syscolumns WHERE Name = 'ToShopId' AND ID = OBJECT_ID('dbo.InOutProdPaper'))
   ALTER TABLE InOutProdPaper ADD ToShopId INT NULL
   
ALTER TABLE dbo.InOutProdPaper
ADD CONSTRAINT rfk_InOutProdPaper_FromShop_FKID FOREIGN KEY
    ( FromShopId ) 
REFERENCES dbo.Shop
    ( Id )

ALTER TABLE dbo.InOutProdPaper
ADD CONSTRAINT rfk_InOutProdPaper_ToShop_FKID FOREIGN KEY
    ( ToShopId ) 
REFERENCES dbo.Shop
    ( Id )
ON DELETE CASCADE